#include "InitState.h"

#include "HoldState.h"
#include "StrategyNode.h"

#include <cstddef>


USING_STOCK_NS
using namespace std;

DealState * InitState::_instance = NULL;

DealState * InitState::GetInstance()
{
	if (_instance == NULL)
	{
		_instance = new InitState();
	}

	return _instance;
}

vector<StrategyNode *> InitState::DoAvailableTransaction(StrategyNode * node, StockPrice curPrice)
{
	vector<StrategyNode *> children;

	StrategyNode * buyNode = new StrategyNode(BUY);
	buyNode->CalcProfit(node->GetProfit(), curPrice);
	buyNode->SetState(HoldState::GetInstance());
	children.push_back(buyNode);

	StrategyNode * passNode = new StrategyNode(PASS);
	passNode->CalcProfit(node->GetProfit(), curPrice);
	passNode->SetState(InitState::GetInstance());
	children.push_back(passNode);

	return children;
}
